package com.delamer.utils;

import com.delamer.facile.db.DBUtilPermit;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;

public class PermitUtil {
    public static boolean hasConfig(String permitName) {
        return Bukkit.getPluginManager().getPlugin("DelamerFacile").getConfig().getStringList("permit").contains(permitName);
    }

    public static boolean hasPermit(String userName, String permitName) {
        try {
            if (Bukkit.getPlayerExact(userName).isOp())
                return true;
            if (hasConfig(permitName))
                if (DBUtilPermit.getPermit(userName, permitName) == null)
                    return false;
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}
